home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / vidbasic.zip / VIDMOVE.ASM < prev    next >
Assembly Source File  |  1990-11-29  |  5KB  |  163 lines

  1. ;«RM82»«TS8,16,24,32,40,48»
  2. ; Updated 11/20/90
  3.  
  4. ;============================================================================
  5. ;   Copyright (C) Copr. 1990 by Sidney J. Kelly
  6. ;           All Rights Reserved.
  7. ;           Sidney J. Kelly
  8. ;           150 Woodhaven Drive
  9. ;           Pittsburgh, PA 15228
  10. ;           home phone 412-561-0950 (7pm to 9:30pm EST)
  11. ;============================================================================
  12.  
  13. ;===========================================================================
  14. ;DECLARE FUNCTION SCN2BUFF  ;put text screen in buffer
  15. ;DECLARE FUNCTION BUFF2SCN  ;get text screen from buffer
  16. ;
  17. ; Allows movement of text screens, page 0 to and from a buffer.
  18. ; Modified to handle a CGA display so will NOT cause SNOW on a CGA
  19. ;
  20. ; Handles only 80*25 displays. Will not crash on 80*43 or 80*50 just wont
  21. ;    save the entire display.
  22. ;
  23. ; Storage in Code Segment used to save space in DGROUP, makes DATA near
  24. ; without using up the limited amount of DGROUP space.  However prevents
  25. ; use of program in OS/2 which prohibits any change to CodeSeg values.
  26. ;===========================================================================
  27.  
  28. DOSSEG
  29. .MODEL MEDIUM
  30.  
  31.         PUBLIC   SCN2BUFF, BUFF2SCN
  32.  
  33. .data
  34.     ;external data so all video routines can access
  35.     EVEN
  36.     EXTRN  B$DVIDEOSEG:WORD
  37.     EXTRN  B$DVIDEOPORT:WORD
  38.     EXTRN  B$DVIDEOINSTL:BYTE
  39. .code
  40.  EXTRN   Get_Adapter:FAR
  41.  INCLUDE  NOWAIT.INC      ;all the video common macros
  42. ;------------------------------Data Area----------------------------------
  43.     EVEN            ;speed up access on an 80286,8086 machine
  44.     BUFF            DW      2000 DUP(?)
  45.  
  46. EVEN
  47. SCN2BUFF   PROC    FAR
  48.     Push            BP             ;Save current display in the buffer
  49.     Push            DS
  50.     Push            SI
  51.     Push            DI
  52.  
  53.         Assume          DS:@data
  54.  
  55.     Cmp             B$DVIDEOINSTL,1
  56.     JE              Skip_Ahead
  57.     Call         Get_Adapter      ;get display information
  58.  
  59. Skip_Ahead:
  60.  
  61.     Mov        DX,B$DVIDEOPORT  ;DX =  VIDEOPORT address or 0
  62.         Mov             AX,CS            ;point ES to CS
  63.     Mov             ES,AX
  64.  
  65.     ;have to be finished with stack or .data before can change DS
  66.         Mov             DS,B$DVIDEOSEG ;DS points to video buffer
  67.  
  68.     ;MUST KEEP THESE TO USE OFFSET RELATIVE TO THE CODE SEGMENT
  69.     Assume        DS:NOTHING, ES:NOTHING
  70.  
  71.         Mov             DI,OFFSET CS:BUFF
  72.     Xor             SI,SI          ;offset of display page 0
  73.  
  74.     ; Move 4,000 bytes between display and the buffer  BUFF
  75.         Cld                            ;all data moves below will be forward
  76.     Mov             CX,2000        ;load counter (2000 words = 4000 bytes)
  77.         Or              DL,DL          ;monochrome or EGA (is DL=0)?
  78.     JZ              Mono           ;yes, skip over the retrace stuff
  79.  
  80. EVEN
  81. CGA_Loop:
  82.         CLI                            ;prevent interrupts
  83.     Wait_CGA_Retrace               ;run CGA retrace macro
  84.     Movsw                          ;move the data in one operation
  85.     STI                            ;allow interrupts again
  86.     Loop            CGA_Loop       ;loop until done
  87.  
  88.     Jmp             Short Exit     ;skip over the mono routine and exit
  89.  
  90. Mono:
  91.     Rep             Movsw          ;move the data in one operation
  92.                        ;Move DS:SI to ES:DI
  93. Exit:
  94.     Pop             DI             ;restore stack
  95.     Pop             SI
  96.     Pop             DS
  97.  
  98.         Assume          DS:@data
  99.  
  100.     Pop             BP
  101.     Ret
  102. SCN2BUFF   ENDP
  103.  
  104. ;===========================================================================
  105. ; Restores saved buffer to screen
  106. ;===========================================================================
  107.  
  108. EVEN
  109. BUFF2SCN   PROC    FAR
  110.     Push            BP                ;Save registers
  111.     Push            DS
  112.     Push            SI
  113.     Push            DI
  114.  
  115.         Assume          DS:@data
  116.  
  117.     Cmp             B$DVIDEOINSTL,1
  118.     JE              skip_over
  119.     Call         Get_Adapter     ;get display information
  120.  
  121. skip_over:
  122.         Mov             ES,B$DVIDEOSEG  ;ES points to video buffer
  123.     Mov             DX,B$DVIDEOPORT ;DX contains B$DVIDEOPORT address or 0
  124.  
  125.     Mov             AX,CS           ;set DS to code segment
  126.     Mov             DS,AX
  127.  
  128.         ;MUST KEEP THESE TO USE OFFSET RELATIVE TO THE CODE SEGMENT
  129.     Assume        DS:NOTHING, ES:NOTHING
  130.  
  131.     Mov             SI, OFFSET CS:BUFF
  132.     Xor             DI,DI        ;offset on screen page 0
  133.  
  134.     Mov             CX, 2000     ;load counter (2000 words = 4000 bytes)
  135.     Cld                          ;all data moves below will be forward
  136.     Or              DL,DL        ;monochrome or EGA (is DL = 0)?
  137.     JZ              Mono1        ;yes, skip over the retrace stuff
  138.  
  139. EVEN
  140. CGA1:
  141.  
  142.     CLI                          ;prevent interrupts
  143.     Wait_CGA_Retrace             ;run CGA retrace macro
  144.     Movsw                        ;move data by words  DS:SI to ES:DI
  145.     STI                          ;allow interrupts again
  146.     Loop            CGA1         ;loop until done
  147.     Jmp             Short Exit1  ;skip over the mono routine and exit
  148.  
  149. Mono1:
  150.     Rep             Movsw        ;move the data in one operation
  151.                      ;Move DS:SI to ES:DI
  152. Exit1:
  153.     Pop             DI           ;restore stack
  154.     Pop             SI
  155.     Pop             DS
  156.  
  157.         Assume          DS:@data
  158.  
  159.     Pop             BP
  160.     Ret
  161. BUFF2SCN   ENDP
  162. END
  163.